#!/usr/bin/python3
def bfs(square, point):
    count = 0
    points = [point]
    while len(points) > 0:
        temp = points.pop()
        for i in range(4):
            x = temp[0] + dx[i]
            y = temp[1] + dy[i]
            if x >= 0 and x <= len(square) - 1 and y >= 0 and y <= len(square[0]) - 1 and square[x][y] != '$':
                if square[x][y] == '*':
                    count += 1
                    square[x][y] = '$'
                    continue
                elif square[x][y] == '.':
                    points.append([x, y])
                    square[x][y] = '$'
                    continue
    return count


try:
    T = int(input())
    # [dx[i],dy[i]]对应上下左右一个格子的移动
    dx = [-1, 1, 0, 0]
    dy = [0, 0, -1, 1]
    for t in range(T):
        n, m = list(map(int, input().split()))
        x, y = list(map(int, input().split()))
        square = []
        for i in range(n):
            temp = input()
            square.append([temp[i:i + 1] for i in range(0, len(temp), 1)])
        point = [x - 1, y - 1]
        print("Case #%d: %d" % (t + 1, bfs(square, point)));
except ValueError:
    pass
except EOFError:
    pass
except MemoryError:
    pass
